package com.ccc.boot.security.service.impl;

import com.ccc.boot.entity.SysUserLoginLog;
import com.ccc.boot.log.ILogService;
import com.ccc.boot.log.LogInfo;
import com.ccc.boot.monitor.mapper.SysUserLoginLogMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * 登录日志表 业务处理实现类
 *
 * @author superC
 * @version 0.1.0
 * @date 2022-04-08
 */
@Service("loginLogService")
public class LoginLogServiceImpl implements ILogService {

    @Autowired
    private SysUserLoginLogMapper sysUserLoginLogMapper;

    @Override
    public void saveLog(LogInfo info) {
        SysUserLoginLog sysLogLogin = new SysUserLoginLog();
        BeanUtils.copyProperties(info, sysLogLogin);
        sysLogLogin.setLoginDate(LocalDate.now().toString());
        sysUserLoginLogMapper.insert(sysLogLogin);
    }

}
